<?php require_once WEB_ROOT_FOLDER."views/header.php"; ?>
<?php if(isset($_SESSION['access_level']) && isset($_SESSION['username']) && ($_SESSION['access_level'] > 4)){?>
<fieldset class="col_12 column">
    <legend class="col_12 column">Tutaj możesz zarządzać statusami komentarzy. Nie możesz ich edytować, za to możesz zmieniać ich status w systemie.</legend>
    <table class="tight" cellpadding="0" cellspacing="0">
        <thead>
            <tr class="alt first last tight">
                <th class="col_3 column" rel="0" value="element">Elementy komentarza</th>
                <th class="col_9 column" rel="1" value="current_value">Aktualna wartość</th>
            </tr>
            <tr class="">
                <td class ="col_3 column">Nazwa użytkownika</td>
                <td class ="col_9 column">
                    <?php if(isset($data['page']['content']['0']['1'])){?>
                    <?php echo $data['page']['content']['0']['1'];?>
                    <?php } ?></td>
            </tr>
            <tr class="">
                <td class ="col_3 column">Status w systemie</td>
                <td class ="col_9 column">
                    <?php if(isset($data['page']['content']['0']['3'])){?>
                    <?php echo $data['page']['content']['0']['3'];?>
                    <?php } ?></td>
            </tr>
            <tr class="">
                <td class ="col_3 column">Zwartość komentarza</td>
                <td class ="col_9 column">
                    <?php if(isset($data['page']['content']['0']['2'])){?>
                    <?php echo $data['page']['content']['0']['2'];?>
                    <?php } ?></td>
            </tr>
            <tr class="">
                <td class ="col_3 column">data utworzenia</td>
                <td class ="col_9 column">
                    <?php if(isset($data['page']['content']['0']['4'])){?>
                    <?php echo $data['page']['content']['0']['4'];?>
                    <?php } ?></td>
            </tr>
        </thead>        
    </table>
    <?php
    if(isset($data['page']['content']['0']['0'])){
    ?>
    
    <form method="post" action="<?php echo SITE_ROOT;?>zarzadzaj-komentarzami/aktualizuj-komentarz.html">
        <input type="hidden" name="id" value="<?php echo $data['page']['content']['0']['0'];?>">
        <?php
        if(isset($data['page']['csrf_token'])){
          ?>
        <input type="hidden" name="csrf_token" value="<?php echo $data['page']['csrf_token'];?>">
        <?php
        }
        ?>
        <?php
        if(isset($data['page']['status']) && is_array($data['page']['status'])){
            if(isset($data['page']['content']['0']['2'])){
            ?>
        <label class="col_12 column" for="status_name">Wybierz nowy status<span class="right">Zmień status na aktywny, ab komentarz pojawiał się na stronie.</span></label><br>
        <select class="col_12 column" name="status_name">
            <?php
            foreach($data['page']['status'] as $key => $value){
                if($data['page']['status'] == $data['page']['content']['0']['3']){
                    ?>
            <option selected="selected" value="<?php echo $value['0'];?>"><?php echo $value['0'];?></option>
            <?php
                }
                else {
                    ?>
            <option value="<?php echo $value['0'];?>"><?php echo $value['0'];?></option>
            <?php
                }
            }
            ?>
        </select><br>
        <?php
            }
        }
        ?>
        <input type="submit" name="submit" value="Aktualizuj status">
    </form>
    <?php
    }
    ?>
</fieldset>
<?php } ?>
<?php require_once WEB_ROOT_FOLDER."views/footer.php";?>

